<?php
function uploadOne($img = 'picUrl', $type = 'thumb')
{

    $file = request()->file($img);
//    halt($_FILES);
    write_log(json_encode($file));
    if (!empty($file)) {

        // 移动到框架应用根目录/public/uploads/ 目录下
        $upload = $file->move(ROOT_PATH . 'public' . DS . 'uploads');

        // halt($upload);
        if ($upload) {

            if ($type == 'thumb') {
                //图片处理
                imgDispose('public' . DS . 'uploads' . DS . $upload->getSaveName());
            }

            //返回图片地址
            return 'uploads/' . date('Ymd') . '/' . $upload->getFilename();
        }
        return $file->getError();
    }
    return request()->param($img,'');
}

function getAuthListt($name,$uid) {
    //if($uid == 1) return true;
    $rules_list = \think\Db::name('auth_group')->alias('a')->join('manager b','a.id = b.level')->where('b.id',$uid)->value('rules');

    $auding_status = \think\Db::name('auth_group')->alias('a')->join('manager b','a.id = b.level')->where('b.id',$uid)->value('auding_status');

    $rules_array = explode(',',$rules_list);

    $auth_rule_list = \think\Db::name('auth_rule')->where('id','in',$rules_array)->select();
    //dump($name);
    if(empty($auth_rule_list)) return false;
    foreach ($auth_rule_list as $k => $v){
        //dump(strtolower($v['name']));
        if($name == strtolower($v['name'])) return true;
    }
    /// halt(1);
    return false;
}
